package com.areong.socket.example;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

import com.areong.socket.SocketClient;
import com.areong.socket.SocketServer;

class SocketExample {
    /**
     * @param args
     * @throws IOException 
     */
    public static void main(String[] args) throws IOException, InterruptedException {
        SocketServer server = new SocketServer(5556, new EchoHandler());
        System.out.println("Server starts.");
        

//            System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());
//            Thread.sleep(3000);// 主线程睡3秒 连接线程就会等待在readline
//            System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());

        

        SocketClient client = new SocketClient(InetAddress.getLocalHost(), 5556);
        System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());
        Thread.sleep(3000);// 主线程睡3秒 连接线程就会等待在readline
        client.println("Hello!");
//        System.out.println(client.readLine());
        System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());
        client.close();
        server.close();
    }
}